-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: JavaScript translations #20
Conversation
4cd0dbe
to
85f3226
Compare
can you explain a bit more why it was failing? |
It was failing because the INSTALLED_APPS = (
"statici18n" # This allows to use the command
)
# statici18n
# https://django-statici18n.readthedocs.io/en/latest/settings.html
LANGUAGES = [
('en', 'English - Source Language'),
('es_419', 'Spanish (Latin America)'),
('es_ES', 'Spanish (Spain)'),
]
STATICI18N_DOMAIN = 'text'
STATICI18N_NAMESPACE = 'MindMapI18N'
STATICI18N_PACKAGES = (
'mindmap',
)
STATICI18N_ROOT = 'mindmap/public/js'
STATICI18N_OUTPUT_DIR = 'translations' Finally, the compile_translations:
...
python manage.py compilejsi18n --namespace MindMapI18N --output $(JS_TARGET) |
Hi @johnvente, the |
Hi @BryanttV in that case doesn't worth to update the files, it's ok for me |
mindmap/public/js/src/mindmap.js
Outdated
@@ -7,6 +7,22 @@ function MindMapXBlock(runtime, element, context) { | |||
const removeGradeURL = runtime.handlerUrl(element, "remove_grade"); | |||
const maxPointsAllowed = context.max_points; | |||
|
|||
let gettext; | |||
if ("MindMapI18N" in window) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if("MindMapI18N" in window || "gettext" in window) {
gettext = window.MindMapI18N?.gettext || window.gettext;
}
if (typeof gettext == "undefined") {
// No translations -- used by test environment
gettext = (string) => string;
}
203e262
to
4670b80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, LGTM!
5a53e14
to
517449b
Compare
Description
This PR adds all configurations to use JavaScript translations.
How To Test
(Account → Site Preferences → Site Language)
. Set it to "Spanish (Latin America)"Using translation commands
make extract_translations
text.po
filemake compile_translations
Screenshots